/*
Copyright (C) 2009-2011 Xanadu Development Team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#include "PlayerHandler.h"
#include "../../tools/PacketReader.h"
#include "../../server/PlayerKeys.h"
#include "../../server/Player.h"
#include "../../server/Key.h"

void PlayerHandler::changeKeyHandle(PacketReader& packet) {
	if (packet.readInt() == 0) {
		int changes = packet.readInt();
		for (int i = 0; i < changes; i++) {
			int pos = packet.readInt();
			char type = packet.read();
			int key = packet.readInt();
			if (key == 0) {
				player->getKeys()->setKey(pos, 0);
			} else {
				player->getKeys()->setKey(pos, new Key(type, key));
			}
		}
		player->saveKeys();
	}
}

void PlayerHandler::changeQuickKeyHandle(PacketReader& packet)
{/*
	 c.getPlayer().clearQuickSlot();
     for (int i = 0; i < 8; i++) {
		c.getPlayer().addQuickSlot(slea.readInt());
     }
     c.getPlayer().saveQuickSlot();*/
}